import asyncio
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent,BrowserSession
from browser_use.llm import ChatOpenAI

# llm = ChatOpenAI(model="o4-mini", temperature=1.0)
llm = ChatOpenAI(model="deepseek-chat",api_key="sk-39ea6cc567614f4e9d565db03174ea5c",base_url="https://api.deepseek.com", temperature=1.0)

browser_session = BrowserSession(    
  executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  user_data_dir='~/.config/browseruse/profiles/default',
)


async def main():

    browser_session = BrowserSession(    
        wss_url="ws://localhost:51118/049a7293a1fa64b25d801049843d0a0f"
        )
    
    agent = Agent(
        task="访问 https://playwright.dev 总结页面内容",
        llm=llm,
        # browser_session=browser_session,
        use_vision=False,
    )
    await agent.run()

    # agent = Agent(

    #     task="Compare the price of gpt-4o and DeepSeek-V3",
    #     llm=llm,
    #     use_vision=False,
    # )
    # await agent.run()

asyncio.run(main())